<?php
/*
 * $id:admin/productimage.php
 *
 * oscProductImage version 1.0
 *
 * Copyright 2011, Zaenal Muttaqin
 * http://blog.lokamaya.net - http://lokamaya.com
 *
 * Licensed under the MIT license:
 * http://creativecommons.org/licenses/MIT/
 *
 */
 
  require('includes/application_top.php');
  require(DIR_WS_CLASSES . 'productImageHandler.php');
  //error_reporting(E_ALL); //for debuggin purpose
  
  $action = isset($_GET['action']) ? $_GET['action'] : 'default';
  
  $opi = new productImageHandler();
  switch ($action) {
    case 'upload':
      //sleep(10);
      $opi->jsonHeader(false);
      $opi->upload();
      //$opi->debug();
      break;
    case 'delete':
      $opi->jsonHeader(true);
      $opi->delete();
      //$opi->debug();
      break;
    case 'getDirectories':
      $opi->jsonHeader(true);
      $opi->getDirectories();
      //$opi->debug();
      break;
    case 'createDirectory':
      $opi->jsonHeader(true);
      $opi->createDirectory();
      //$opi->debug();
      break;
    case 'browseFiles':
      $opi->jsonHeader(true);
      $opi->browseFiles();
      //$opi->debug();
      break;
    case 'cleanUp':
      $opi->jsonHeader(true);
      $opi->cleanUp();
      //$opi->debug();
      break;
    default:
      $opi->jsonHeader(true);
  }
    
  $opi->jsonOutput();
  tep_session_close();
?>